package com.tencent.welink.api.msg;

import com.alibaba.fastjson.JSONObject;
import com.tencent.welink.api.OpenApiTokenChange;
import com.tencent.welink.api.base.WelinkOpenApi;
import com.tencent.welink.config.BussinessConfig;
import com.tencent.welink.util.CrontabUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Map;

/**
 * @Description: 智能设备控制
 * 用于发送消息到设备，需要实现对应设备协议。
 * @Author: limye
 * @CreateDate: 2020-6-8
 * @Version: V1.0
 */
public class MessageController extends WelinkOpenApi {

    private static final Logger log = LogManager.getLogger(MessageController.class);

    public MessageController(){
        super("/common/msg/controller",true);
    }


    @Override
    public void displayResult(String result) {
    }


    public static void main(String[] args) {
        new BussinessConfig();
        CrontabUtil.addTaskInRate(new OpenApiTokenChange(), BussinessConfig.loginDurationMinutes,true);

        //实例化对象
        MessageController instance = new MessageController();

        //添加参数
        Map<String,Object> map = instance.getExtendsPara();
        map.put("din","300000000000070736");
        map.put("wId","31b7a8ef-e8e3-4f41-af95-ce0f3af8fa47");

        JSONObject data = new JSONObject();
        data.put("seq",1);
        data.put("sub_id","300000000000070739");
        data.put("timestamp",System.currentTimeMillis());
        data.put("cmd","{" +
                "    \"bri\":50," +
                "    \"on\":true," +
                "    \"rgb\":[100,100,100]," +
                "    \"ct\":100}" +
                "    }");

        map.put("data",data);

        //执行HTTP请求及展示结果
        instance.DoHttp();
        CrontabUtil.shutdown();

    }
}
